package run.halo.app.core.endpoint.theme;

import lombok.Builder;
import lombok.Data;
import run.halo.app.core.extension.content.ProductType;

import java.time.Instant;
import java.util.List;

/**
 * Value object for ProductType.
 *
 * @author halo-product-management
 * @since 2.0.0
 */
@Data
@Builder
public class ProductTypeVo {
    
    private String name;
    private String displayName;
    private String description;
    private List<String> images;
    private Integer priority;
    private Integer productCount;
    private Instant creationTimestamp;
    
    /**
     * Convert ProductType to ProductTypeVo.
     *
     * @param productType ProductType extension
     * @return ProductTypeVo
     */
    public static ProductTypeVo from(ProductType productType) {
        return ProductTypeVo.builder()
            .name(productType.getMetadata().getName())
            .displayName(productType.getSpec().getDisplayName())
            .description(productType.getSpec().getDescription())
            .images(productType.getSpec().getImages())
            .priority(productType.getSpec().getPriority())
            .productCount(productType.getStatusOrDefault().getProductCount())
            .creationTimestamp(productType.getMetadata().getCreationTimestamp())
            .build();
    }
}